package com.github.catvod.spider.merge;

import com.github.catvod.spider.merge.HZ;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import javax.annotation.Nullable;

/* loaded from: classes.dex */
public class tF implements Map.Entry<String, String>, Cloneable {
    private static final String[] h = {"allowfullscreen", "async", "autofocus", "checked", "compact", "declare", "default", "defer", "disabled", "formnovalidate", "hidden", "inert", "ismap", "itemscope", "multiple", "muted", "nohref", "noresize", "noshade", "novalidate", "nowrap", "open", "readonly", "required", "reversed", "seamless", "selected", "sortable", "truespeed", "typemustmatch"};
    private String V0;

    @Nullable
    private String j;

    @Nullable
    QF q;

    public tF(String str, @Nullable String str2, @Nullable QF qf) {
        R2.u(str);
        String trim = str.trim();
        R2.BQ(trim);
        this.V0 = trim;
        this.j = str2;
        this.q = qf;
    }

    protected static boolean BQ(String str) {
        return Arrays.binarySearch(h, str) >= 0;
    }

    protected static void oC(String str, @Nullable String str2, Appendable appendable, HZ.Tw tw) {
        appendable.append(str);
        if (u(str, str2, tw)) {
            return;
        }
        appendable.append("=\"");
        XR.I(appendable, QF.W(str2), tw, true, false, false);
        appendable.append('\"');
    }

    protected static boolean u(String str, @Nullable String str2, HZ.Tw tw) {
        return tw.Qy() == HZ.Tw.EnumC0010Tw.html && (str2 == null || ((str2.isEmpty() || str2.equalsIgnoreCase(str)) && BQ(str)));
    }

    protected void I(Appendable appendable, HZ.Tw tw) {
        oC(this.V0, this.j, appendable, tw);
    }

    @Override // java.util.Map.Entry
    /* renamed from: V0, reason: merged with bridge method [inline-methods] */
    public String getKey() {
        return this.V0;
    }

    @Override // java.util.Map.Entry
    /* renamed from: W, reason: merged with bridge method [inline-methods] */
    public String setValue(String str) {
        String str2 = this.j;
        QF qf = this.q;
        if (qf != null) {
            str2 = qf.oq(this.V0);
            int y = this.q.y(this.V0);
            if (y != -1) {
                this.q.j[y] = str;
            }
        }
        this.j = str;
        return QF.W(str2);
    }

    @Override // java.util.Map.Entry
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || tF.class != obj.getClass()) {
            return false;
        }
        tF tFVar = (tF) obj;
        String str = this.V0;
        if (str == null ? tFVar.V0 != null : !str.equals(tFVar.V0)) {
            return false;
        }
        String str2 = this.j;
        String str3 = tFVar.j;
        return str2 != null ? str2.equals(str3) : str3 == null;
    }

    /* renamed from: h, reason: merged with bridge method [inline-methods] */
    public tF clone() {
        try {
            return (tF) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }

    @Override // java.util.Map.Entry
    public int hashCode() {
        String str = this.V0;
        int hashCode = (str != null ? str.hashCode() : 0) * 31;
        String str2 = this.j;
        return hashCode + (str2 != null ? str2.hashCode() : 0);
    }

    @Override // java.util.Map.Entry
    /* renamed from: j, reason: merged with bridge method [inline-methods] */
    public String getValue() {
        return QF.W(this.j);
    }

    public String q() {
        StringBuilder V0 = ZG.V0();
        try {
            I(V0, new HZ("").TD());
            return ZG.t(V0);
        } catch (IOException e) {
            throw new zx(e);
        }
    }

    public String toString() {
        return q();
    }
}
